(function (id) {
    $.ajax({
        url:'/rest/front/news/selectAllList',
        Type:'GET',
        dataType:'json',
        success:function (data) {
            var list=data.data,btnhtml='',index;
            $.each(list,function (i, e) {
                if(e.id==id){
                    index=i;
                    $(".newsName").click(function(){
                        window.location.href="https://zlgpy.com/zlkx.html?categoryName="+e.categoryName;
                    });
                    return false;
                }
            });
            var size=list.length-1;
            var prev,next;
            index>0?prev=index-1:prev=size;
            index<size?next=index+1:next=0;
            btnhtml+='<div class="prevPage" onclick="gonews('+list[prev].id+')"><h2>上一篇:</h2><h5>'+list[prev].name+'</h5></div>'+
                '<div class="nextPage" onclick="gonews('+list[next].id+')"><h2>下一篇:</h2><h5>'+list[next].name+'</h5></div>';
            $('.buttonPage').html(btnhtml);
            $('.prevBtn').attr('data-id',list[prev].id);
            $('.nextBtn').attr('data-id',list[next].id);
            var sHtml="";
            sHtml+= '<div class="bdsharebuttonbox"><a class="bds_more" href="" data-cmd="more"></a> <a title="分享到QQ空间" class="bds_qzone" href="#" data-cmd="qzone" data-id="'+id+'"></a>'+
                '<a title="分享到新浪微博" class="bds_tsina" href="#" data-cmd="tsina" data-id="'+id+'"></a><a title="分享到腾讯微博" class="bds_tqq" href="#" data-cmd="tqq" data-id="'+id+'"></a></div>';
            $(".bdsharebuttonbox-pc,.bdsharebuttonbox-mobile ").html(sHtml);

            //全局变量，动态的文章ID
            var ShareId = "";
//绑定所有分享按钮所在A标签的鼠标移入事件，从而获取动态ID
            $(function () {
                $(".bdsharebuttonbox a,.bdsharebuttonbox-mobile a ").mouseover(function () {
                    ShareId = $(this).attr("data-id");
                });
            });
            /*
                * 动态设置百度分享URL的函数,具体参数
                * cmd为分享目标id,此id指的是插件中分析按钮的ID
                *，我们自己的文章ID要通过全局变量获取
                * config为当前设置，返回值为更新后的设置。
                */
            function SetShareUrl(cmd, config) {
                if (ShareId) {
                    config.bdUrl = "https://zlgpy.com/zlkx/"+id+".html";
                }
                return config;
            }

//插件的配置部分，注意要记得设置onBeforeClick事件，主要用于获取动态的文章ID
            window._bd_share_config = {
                "common": {
                    onBeforeClick:SetShareUrl,"bdSnsKey":{},"bdText":"","bdMini":"2"
                    ,"bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"
                }, "share": {}
            };
//插件的JS加载部分
            with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = '/static/api/js/share.js?v=89860593.js?'];
            //点击分享出现分享插件
            $(".shareBtn ").click(function(){
                $(".bdsharebuttonbox-mobile").show();
            });

        }
    });

})(id);


/**
 * 查询推荐的内容
 */
(function(){
    $.ajax({
        type: 'GET',
        dataType: 'json',
        url: '/rest/front/news/selectAllList',
        data:{
            isRecommend:'y'
        },
        success:function(data){
            var recommendList=data.data,
                recommendHtml="",
                recommendPcHtml="";
            $.each(recommendList,function(i,o){
                recommendPcHtml+='<li class="li-introduce"><a href="../zlkx/'+o.id+'.html"><p class="p-name">'+o.name+'</p><p class="p-introduce">'+o.introduce+'</p><span>'+o.createTime+'</span></a></li>';
                recommendHtml+='<li><a href="../zlkx/'+o.id+'.html"><img src="/'+o.headImage+'"><div class="list-content">'+
                    '<p class="p-name">'+o.name+'</p><p class="p-introduce"><span>发布日期：'+o.createTime+'</span></div></a></li>'
            });
            $(".recommend-li").after(recommendPcHtml);//pc端的查询
            $(".recommend-list").html(recommendHtml);//移动端查询
            dotNews();
        }
    })
})();
/**
 * 查询最热的内容
 */
(function(){
    $.ajax({
        type: 'GET',
        dataType: 'json',
        url: '/rest/front/news/selectAllList',
        data:{
            isHot:'y'
        },
        success:function(data){
            var hotList=data.data,
                hotHtml="",
                hotPcHtml="";
            $.each(hotList,function(i,o){
                hotPcHtml+='<li class="li-introduce"><a href="../zlkx/'+o.id+'.html"><p class="p-name">'+o.name+'</p><p class="p-introduce">'+o.introduce+'</p><span>'+o.createTime+'</span></a></li>';
                hotHtml+='<li><a href="../zlkx/'+o.id+'.html"><img src="/'+o.headImage+'"><div class="list-content">'+
                    '<p class="p-name">'+o.name+'</p><p class="p-introduce">'+o.introduce+'</p><span>发布日期：'+o.createTime+'</span></div></a></li>'
            });
            $(".hotPC-li").after(hotPcHtml);
            $(".hotMobile-list").html(hotHtml);
            dotNews();
        }
    })
})();
function gonews(id) {
    window.location.href='../zlkx/'+id+'.html';
}
$('.j-btn').click(function () {
   var id=$(this).data('id');
    gonews(id)
});